#ifndef PROPERTYFILTER_H
#define PROPERTYFILTER_H

#include "url.h"
#include "sh_global.h"

class QObject;
class ShNet;

class SHSHARED_EXPORT PropertyFilter
{
    friend class ShNet;

    PropertyFilter();
public:
    enum PROPERTY_FILTER_TYPE { PROPERTY_SET, SLOT_CALL };
    /**
     * @brief installPropertyChangeFilter set property or call method when property changes
     * @param property smth like this: abc/[group]/property1
     * @param filterType PROPERTY_SET or METHOD_CALL
     * @param reciever QObject with property or method void f(QVariant)
     * @param methodOrPropertyName name of method without () or property
     * return index of filter
     */
    int add(const Url &property,
            PROPERTY_FILTER_TYPE filterType,
            QObject *reciever,
            const char *slotOrPropertyName);
    /**
     * @brief removePropertyChangeFilter Removes installed filter
     * @param filterIdx idx returned by installPropertyChangeFilter
     */
    void remove(int filterIdx);
    /**
     * @brief addSignal add signal to this network, broadcast it when source->sourceSignalName signal catched
     * @param name signal name in this network
     * @param source QObject with sourceSignalName signal
     * @param sourceSignalName
     * example addSignal("signal_net_name", object, SIGNAL(signal1(QVariant))
     */

private:
    void filter(const Url &propertyUrl);
    typedef struct {
        Url properties;
        PROPERTY_FILTER_TYPE type;
        QObject *object;
        const char *methodOrProperty;
    } property_filter_t;
    QHash<int, property_filter_t> m_propertyFilters;
};

#endif // PROPERTYFILTER_H
